<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../resource/js/layuimini-v2/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../resource/js/layuimini-v2/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="../resource/js/layuimini-v2/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>创建数据库连接</legend>
        </fieldset>

        <div class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">连接名</label>
                <div class="layui-input-block">
                    <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入连接名" class="layui-input name">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">主机IP地址</label>
                <div class="layui-input-block">
                    <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入主机或IP地址" class="layui-input host">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">端口</label>
                <div class="layui-input-block">
                    <input type="number" name="title" lay-verify="title" autocomplete="off" placeholder="请输端口" class="layui-input port">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-block">
                    <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输用户名" class="layui-input user">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input type="password" name="password" placeholder="请输入密码" autocomplete="off" class="layui-input password">
                </div>
            </div>
        </div>
    </div>
</div>

<script src="../resource/js/layuimini-v2/lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="../resource/js/layuimini-v2/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    function save(){
        var data = {
            name: $(".name").val(),
            host: $(".host").val(),
            port: $(".port").val(),
            user: $(".user").val(),
            password: $(".password").val()
        }

        $.ajax({
            url:"/td/add/post",
            type:"POST",
            data:data,
            dataType : 'json',
            async:false,
            success:function (res) {
                console.info(res)
            },
            error:function(){

            }
        });
    }
</script>

</body>
</html>